home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / CHIP / Porady / Srodowisko PHP-MySQL / PHP4 ADD-ON / PHP4_add-on.exe / {app} / php4 / switch.php < prev   
PHP Script  |  2004-07-22  |  2KB  |  62 lines

  1. <?
  2.  
  3. $lmphp4 = "php4/sapi/php4apache.dll";
  4. $lmphp5 = "php/php5apache.dll";
  5. $uphp4 =  "AddModule mod_php4.c";
  6. $uphp5 = "AddModule mod_php5.c";
  7. $mphp4 = "php4_module";
  8. $mphp5 = "php5_module";
  9.  
  10. $phpinifile = "../apache/php.ini";
  11.  
  12.  
  13.  
  14. $myhttpd = @file_get_contents("../apache/conf/httpd.conf") or die (" 
  15. fichier httpd.conf non trouve
  16. ");
  17. echo("
  18. Please wait while stopping Apache service...");
  19. exec ("NET STOP WAMPAPACHE");
  20.  
  21. if (eregi($lmphp4,$myhttpd))
  22. {
  23.     $version = 4;
  24.     $myhttpd = ereg_replace ($lmphp4,$lmphp5,$myhttpd);
  25.     $myhttpd = ereg_replace ($uphp4,$uphp5,$myhttpd);
  26.     $myhttpd = ereg_replace ($mphp4,$mphp5,$myhttpd);
  27.     rename ("../apache/php.ini","../apache/php4.ini");
  28.     rename ("../apache/php5.ini","../apache/php.ini");
  29.     echo("
  30. Switching from PHP4 to PHP5...
  31. ");
  32. }
  33. else
  34. {
  35.     $version = 5;
  36.     $myhttpd = ereg_replace ($lmphp5,$lmphp4,$myhttpd);
  37.     $myhttpd = ereg_replace ($uphp5,$uphp4,$myhttpd);
  38.     $myhttpd = ereg_replace ($mphp5,$mphp4,$myhttpd);
  39.     rename ("../apache/php.ini","../apache/php5.ini");
  40.     rename ("../apache/php4.ini","../apache/php.ini");
  41.     echo("
  42. Switching from PHP5 to PHP4...
  43. ");
  44.     }
  45.  
  46. $fp = fopen("../apache/conf/httpd.conf","w");
  47. fwrite($fp,$myhttpd);
  48. echo ("Please wait while restarting Apache service...");
  49. exec ("NET START WAMPAPACHE");
  50.  
  51. $mywampini = @file_get_contents("../wampserver.ini") or die (" 
  52. fichier httpd.conf non trouve
  53. ");
  54. if ($version == 5)
  55.     $mywampini = ereg_replace ("Switch to PHP4","Switch to PHP5",$mywampini);
  56. else
  57.     $mywampini = ereg_replace ("Switch to PHP5","Switch to PHP4",$mywampini);
  58. $fp2 = fopen("../wampserver.ini","w");
  59. fwrite($fp2,$mywampini);
  60.  
  61. ?>
  62.